package com.njxzc.igo.controller.address;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.njxzc.igo.service.AddressService;
import com.njxzc.igo.service.AddressServiceImpl;
import com.njxzc.igo.utils.JsonUtil;
import com.njxzc.igo.utils.ShoppingResult;

import net.sf.json.JSONObject;


@WebServlet(name="loadAllRegions",urlPatterns="/loadregion.do")
public class LoadRegionInfoController extends HttpServlet{
	private AddressService as = new AddressServiceImpl();

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		PrintWriter out = response.getWriter();
		String cityId = request.getParameter("cityId");
		ShoppingResult rs = as.loadAllRegionByCityId(cityId);
		JSONObject jo  = JSONObject.fromObject(rs,JsonUtil.solveProvincelazy());
		out.println(jo.toString());
	}
}
